package com.loong.system.handler;

import com.loong.common.google.param.PlaceAutoCompleteParam;
import com.loong.common.google.param.PlaceDetailParam;
import com.loong.common.google.place.PlaceUtils;
import com.loong.common.google.result.PlaceAutoCompleteResult;
import com.loong.common.google.result.PlaceDetailResult;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class GoogleMapHandler {

    @Resource
    private PlaceUtils placeUtils;

    public List<PlaceAutoCompleteResult> search(PlaceAutoCompleteParam placeAutoCompleteParam) {
        List<PlaceAutoCompleteResult> places = placeUtils.getPlaces(placeAutoCompleteParam);
        return places;
    }

    public PlaceDetailResult.LocationBean detail(PlaceDetailParam placeAutoCompleteParam) {
        return placeUtils.getPlaceDetail(placeAutoCompleteParam).getGeometry().getLocation();
    }

}
